//// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
//package com.linqingying.gitcode.pullrequest.ui.review
//
//import com.intellij.collaboration.async.classAsCoroutineName
//import com.intellij.collaboration.async.computationState
//import com.intellij.collaboration.async.stateInNow
//import com.intellij.collaboration.util.ComputedResult
//import com.intellij.platform.util.coroutines.childScope
//import kotlinx.coroutines.CoroutineScope
//import kotlinx.coroutines.flow.SharedFlow
//import kotlinx.coroutines.flow.StateFlow
//import com.linqingying.gitcode.pullrequest.config.GitCodePullRequestsProjectUISettings
//import com.linqingying.gitcode.pullrequest.data.GCPRIdentifier
//import com.linqingying.gitcode.pullrequest.data.provider.GCPRDataProvider
//import com.linqingying.gitcode.pullrequest.data.provider.changesRequestFlow
//import com.linqingying.gitcode.pullrequest.ui.GCPRReviewBranchStateSharedViewModel
//import com.linqingying.gitcode.pullrequest.ui.toolwindow.model.GCPRToolWindowProjectViewModel
//
//interface GCPRBranchWidgetViewModel : GCPRReviewViewModel {
//  val id: GCPRIdentifier
//
//  val updateRequired: StateFlow<Boolean>
//  val dataLoadingState: StateFlow<ComputedResult<Any>>
//  val editorReviewEnabled: StateFlow<Boolean>
//
//  val updateErrors: SharedFlow<Exception>
//
//  fun showPullRequest()
//  fun updateBranch()
//  fun toggleEditorReview()
//}
//
//internal class GCPRBranchWidgetViewModelImpl(
//  parentCs: CoroutineScope,
//  private val settings: GitCodePullRequestsProjectUISettings,
//  dataProvider: GCPRDataProvider,
//  private val projectVm: GCPRToolWindowProjectViewModel,
//  private val sharedBranchVm: GCPRReviewBranchStateSharedViewModel,
//  private val reviewVmHelper: GCPRReviewViewModelHelper,
//  override val id: GCPRIdentifier
//) : GCPRBranchWidgetViewModel, GCPRReviewViewModel by DelegatingGCPRReviewViewModel(reviewVmHelper) {
//  private val cs = parentCs.childScope(classAsCoroutineName())
//
//  override val updateRequired: StateFlow<Boolean> = sharedBranchVm.updateRequired
//
//  override val dataLoadingState: StateFlow<ComputedResult<Any>> =
//    dataProvider.changesData.changesRequestFlow().computationState().stateInNow(cs, ComputedResult.loading())
//
//  override val editorReviewEnabled: StateFlow<Boolean> = settings.editorReviewEnabledState
//
//  override val updateErrors: SharedFlow<Exception> = sharedBranchVm.updateErrors
//
//  override fun showPullRequest() {
//    projectVm.viewPullRequest(id)
//  }
//
//  override fun updateBranch() = sharedBranchVm.updateBranch()
//
//  override fun toggleEditorReview() {
//    settings.editorReviewEnabled = !settings.editorReviewEnabled
//  }
//}
